﻿'use strict'

var people = [
    {
        name: "Bob",
        age: 25,
    },
    {
        name: "Alice",
        age: 27,
    },
    {
        name: "John",
        age: 30,
    },
    {
        name: "Mike",
        age: 35,
    },
    {
        name: "Amy",
        age: 40,
        address: ""
    }
];

var names = people.map(function (person) {
    return person.name;
});

//var collection = people.filter(function (person) {
//    return person.age >= 30;
//});

//for (var i = 0; i < collection.length; i++) {
//    console.log(collection[i].name + ' ' + collection[i].age);
//}

people.filter(function (person) {
    return person.age >= 30;
}).sort(function (a, b) {
    return a.name.localeCompare(b.name);
}).map(function (person, index) {
    return + ":" + person.name + "\t" + person.age
}).forEach(function (s) {
    console.log(s);
});